package de.gameduell.framework.application {
	import de.gameduell.framework.gui.popup.Popup;	
	import de.gameduell.framework.debug.Debug;	
	import de.gameduell.net.src.communication.CommunicationEvent;	
	import de.gameduell.framework.application.Game;
	import de.gameduell.framework.application.controller.MultiplayerController;	

	public class MultiplayerGame extends Game {

		private const ERROR_POPUP_TIME:int = 999999;
		private var _controller:MultiplayerController;
		protected var connectionLostPopup:Popup;

		public function MultiplayerGame() {

		}
		
		/**  
		 * @param aController = the MultiplayerController of the current application 
		**/	
		protected function set controller(aController:MultiplayerController):void {
			_controller = aController;
			initController(aController);
			_controller.chatExists = settings.chatExists;
		}
		
		/**  
		 * shows the disconnection popup if the connection failed
		**/
		override protected function onDisconnected(event:CommunicationEvent):void {
			Debug.trace("Game::onDisconnected");
			connectionLostPopup = new Popup("errorPopup","connectionLostPopup",ERROR_POPUP_TIME, true);
			connectionLostPopup.modal = true;
			connectionLostPopup.registerButton("send", _controller.exit);
			connectionLostPopup.addEventListener(Popup.HIDE, _controller.exit);
			connectionLostPopup.show();
		}
	}
}
